import { getCommentListService } from '../../../model/service/comment/getCommentListService';
import { sendCommentService } from '../../../model/service/comment/sendCommentService';

// 获取视频的评论
export async function getVideoComment(ctx: Context, next: Next) {
  const { body } = ctx.request;
  const { videoId, pageSize, pageNum } = body;

  try {
    const result = await getCommentListService({videoId, pageSize, pageNum});
    ctx.api.success(result, 'success');
  } catch (error) {
    ctx.api.fail(-1, '查询失败')
  }

  return next();
}

// 发送评论
export async function sendComment(ctx: Context, next: Next) {
  const { body } = ctx.request;

  try {
    const result = await sendCommentService(body);
    ctx.api.success(result, 'success');
  } catch (error) {
    ctx.api.fail(-1, '查询失败')
  }


  return next();
}
